using UnityEngine;
using UnityEngine.EventSystems;

public class BoardClickHandler : MonoBehaviour, IPointerClickHandler
{
    [SerializeField] private GameBoard gameBoard;

    public void OnPointerClick(PointerEventData eventData)
    {
        RectTransform rectTransform = GetComponent<RectTransform>();
        
        // 转换屏幕坐标到本地坐标
        Vector2 localPoint;
        RectTransformUtility.ScreenPointToLocalPointInRectangle(
            rectTransform, 
            eventData.position, 
            eventData.pressEventCamera, 
            out localPoint
        );

        gameBoard.OnBoardClick(localPoint);
    }
}
